home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks95
/
Aaron 1.0b3.sit
/
Aaron 1.0b3
/
Aaron Source
/
INIT.c
< prev
next >
Wrap
Text File
|
1995-06-24
|
3KB
|
141 lines
/* Aaron © 1995 Gregory D. Landweber, ALL RIGHTS RESERVED */
#include <Notification.h>
//#include "GB.h"
#include "ShowInitIcon.h"
#include <A4Stuff.h>
void PatchFinder( void );
pascal void Response ( NMRecPtr myRequest );
void Notice ( void );
long runable ( void );
void main ( void );
void KeepMeAround ( short refNum );
/*
pascal void Response ( NMRecPtr myRequest )
{
NMRemove ( myRequest );
if ( myRequest->nmStr )
DisposHandle ( RecoverHandle ((Ptr)myRequest->nmStr) );
DisposPtr ( (Ptr)myRequest->nmResp );
DisposPtr ( (Ptr)myRequest );
}
void Notice ()
{
long size, thePtr;
NMRecPtr myRequest;
StringHandle theString;
if ( thePtr = (long)NewPtrSys( size = (long)&Notice - (long)&Response ) ) {
BlockMove ( (Ptr)&Response, (Ptr)thePtr, (Size)size );
myRequest = (NMRecPtr) NewPtrSys ( sizeof( NMRec ) );
myRequest->qType = nmType;
myRequest->nmMark = 0;
myRequest->nmIcon = 0;
myRequest->nmSound = (Handle) -1;
if ( theString = GetString( -10240 ) ) {
DetachResource ((Handle)theString);
HLock ((Handle)theString);
myRequest->nmStr = *theString;
}
else
myRequest->nmStr = 0;
myRequest->nmResp = NewNMProc(thePtr);
myRequest->nmRefCon = 0;
NMInstall (myRequest);
}
}
*/
// 680x0 code only
/* Code to keep an INIT file opened at boot time around all the time, à la
SuitCase II et al. */
typedef struct _res_map res_map;
typedef struct _res_map *res_map_ptr;
typedef struct _res_map **res_map_handle;
struct _res_map {
long void1; /* Reserved */
long void2; /* Reserved */
long void3; /* Reserved */
long void4; /* Reserved */
res_map_handle next_map; /* Handle of next resource map */
short refNum; /* fRefNum for this file */
short fileAttrs; /* Resource file attributes for this file */
short tlOffset; /* Type List Offset from beginning of map */
short nlOffset; /* Name List Offset from beginning of map */
};
void KeepMeAround ( short refNum )
{
THz saved_zone;
res_map_handle map_copy;
res_map_handle the_map;
the_map = (res_map_handle)LMGetTopMapHndl();
if ( (*the_map)->refNum == refNum ) {
map_copy = the_map;
LMSetTopMapHndl ( (Handle) (*the_map)->next_map );
}
else {
map_copy = (*the_map)->next_map;
while ( (*map_copy)->refNum != refNum ) {
the_map = map_copy;
map_copy = (*the_map)->next_map;
}
(*the_map)->next_map = (*map_copy)->next_map;
the_map = map_copy;
}
saved_zone = GetZone();
SetZone ( LMGetSysZone() );
HandToHand ( (Handle *)&map_copy );
SetZone(saved_zone);
DisposHandle((Handle)the_map);
the_map = (res_map_handle)LMGetSysMapHndl();
while ( (*the_map)->next_map )
the_map = (*the_map)->next_map;
(*the_map)->next_map = map_copy;
(*map_copy)->next_map = nil;
}
long runable(void)
{
SysEnvRec the_environment; /* Environment record to determine if Color QD is implemented */
SysEnvirons(1,&the_environment); /* Have machine tell us the environment */
return (the_environment.hasColorQD && the_environment.systemVersion >= 0x0700);
}
void main ( void )
{
short refNum;
long oldA4 = SetCurrentA4();
refNum = CurResFile();
if ( !Button() && runable() ) {
Handle patches = GetResource ( 'PACH', 130 );
if ( patches && *patches ) {
DetachResource ( patches );
KeepMeAround ( refNum );
( ( void (*) ( short ) ) StripAddress ( *patches ) ) ( refNum );
}
ShowInitIcon( -1000, true );
// Notice();
}
else
ShowInitIcon( -1000, true );
SetA4 ( oldA4 );
}